home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / CC_C / 1116.ZIP / TOOLKIT.ARC / _FILES.C next >
Text File  |  1979-12-31  |  1KB  |  38 lines

  1.  
  2. /* _FILES.C
  3.             This Small C program demonstrates fprintf().
  4.             Note: HEXPRINT.C demonstrates hexprint()
  5.                   which is also a function found in _FILES.H
  6. */
  7.  
  8. #include _files.h
  9.  
  10. main()
  11.        {
  12.          int *fout,nout;
  13.          fout = fopen("_FILES.DAT","W");
  14.          putc(13,fout);
  15.          putchar(13);
  16.          puts("Enter a number from 0 to 9: "); nout = getchar(nout);
  17.          putchar(13); putchar(13);
  18.          if((nout<48)|(nout>57))
  19.              { puts("error, 0-9 only"); fclose(fout); exit(); }
  20.          nout = nout - 48;
  21.          fprintf("A number is written to this file by _FILES.C\n\n",0,fout);
  22.          putc(13,fout);
  23.          fprintf("In decimal, the number is: ",0,fout);
  24.          fprintf("%d",nout,fout); putc(13,fout);
  25.          fprintf("In hexadecimal, the number is: ",0,fout);
  26.          fprintf("%h",nout,fout); putc(13,fout);
  27.          fprintf("In octal, the number is: ",0,fout);
  28.          fprintf("%o",nout,fout); putc(13,fout);
  29.          fprintf("In binary, the number is: ",0,fout);
  30.          fprintf("%b",nout,fout); putc(13,fout);
  31.          puts("Look at the new ASCII file  _FILES.DAT to see the result.");
  32.          putchar(13); putchar(13);
  33.          fclose(fout);
  34.        }
  35.  
  36.  
  37.  
  38.